echo "部署 $appName ..."

server_host=dc-app

subs=$(ls -l docker-app | grep '^d' | awk '{print $NF}'| xargs | sed "s| |,|g")
echo "curl -X POST  --max-time 6 --retry 3 http://$server_host/api/shell/mkdir?path=%2Fapp%2Fweb%2F$appName"'&subs='$subs
curl -X POST  --max-time 6 --retry 3 'http://$server_host/api/shell/mkdir?path=%2Fapp%2Fweb%2F'$appName'&subs='$subs

$sudo scp -r docker-app/*   root@$server_host:/app/web/$appName/

echo "curl -X POST -o curl-result.txt -s -w  %{http_code} --max-time 6 --retry 3 http://$server_host:9898/shell/run-ng"

code=$(curl -X POST -o curl-result.txt -s -w  %{http_code} --max-time 6 --retry 3 http://$server_host:9898/shell/run-ng)


if [ "$code" == "000" ]; then
    echo "网络错误，请重试！"
    exit 3;
elif [ "$code" == "200" ]; then
    echo -e "\n"`date "+%Y-%m-%d %H:%M:%S"` '启动nginx 成功!'
else
    echo -e "\n"`date "+%Y-%m-%d %H:%M:%S"` '启动nginx 失败!!! 返回: $code'
    cat curl-result.txt
    exit 1
fi

echo "部署 $appName 完成"